package cn.yunhe.service.impl;

import cn.yunhe.dao.IAdminDao;
import cn.yunhe.entity.Admin;
import cn.yunhe.service.IAdminService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Getter
@Setter
public class AdminService implements IAdminService {
    @Autowired
    @Qualifier(value = "adminDao")
    private IAdminDao adminDao;
    @Override
    public List<Admin> getAll() {
        return adminDao.getAll();
    }

    @Override
    public void register(Admin admin) {
        adminDao.register(admin);
    }

    @Override
    public Admin login(String a_name, String a_pwd) {
        if ((a_name!=null && !"".equals(a_name))&&(a_pwd!=null && !"".equals(a_pwd))){
            return adminDao.login(a_name,a_pwd);
        }else {
            return null;
        }

    }

    @Override
    public Admin get(int a_id) {
        return adminDao.get(a_id);
    }
}
